package com.jkgh.remedium.objects {
	
	import com.jkgh.remedium.RemediumSystem;
	import com.jkgh.remedium.objects.messages.RemediumInMessage;
	import com.jkgh.remedium.objects.messages.RemediumOutMessage;
	
	public class RemediumMethodObject extends RemediumObject {
		
		protected var hostID:int;
		protected var objectID:int;
		
		public function RemediumMethodObject(remedium:RemediumSystem, hostID:int, objectID:int, registry:RemediumSystem) {
			if (remedium != null) {
				this.hostID = remedium.getHostID();
				this.objectID = remedium.nextObjectID();
				remedium.registerMethodObject(this.hostID, this.objectID, this);
			} else {
				this.hostID = hostID;
				this.objectID = objectID;
				registry.registerMethodObject(hostID, objectID, this);
			}
		}
	
		public function call(remedium:RemediumSystem, message:RemediumInMessage, callID:int, methodID:int, callback:Function):void {
			throw new Error();
		}
		
		override public final function produceContent(remedium:RemediumSystem, message:RemediumOutMessage):void {
			remedium.consumeInt(hostID);
			remedium.consumeInt(objectID);
		}
	}
}